package com.lqian.utils;

//分页
public class PageUtil {
	
	private Integer count;//总的数据条数
	private Integer pageSize;//每页的数据量
	private Integer curPage;//页码	
	
	//计算出来的
	private Integer pages;	//总页数
	private Integer start;//开始查询的位置
	
	public PageUtil(Integer count, Integer pageSize, Integer curPage) {
		this.count = count;
		this.pageSize = pageSize;
		this.curPage = curPage;
		
		this.setPages();
		this.setStart();		
	}
	
	
	public Integer getCount() {
		return count;
	}
	public void setCount(Integer count) {
		this.count = count;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	public Integer getCurPage() {
		return curPage;
	}
	public void setCurPage(Integer curPage) {
		this.curPage = curPage;
	}
	public Integer getPages() {
		return pages;
	}
	public void setPages() {
		//如果不能整除+1
		int num=count/pageSize;
		this.pages = count%pageSize==0?num:(num+1);
	}
	public Integer getStart() {
		return start;
	}
	public void setStart() {
		this.start = (curPage-1)*pageSize;
	}
}
